package com.yaorange.module.security.controller;

import com.yaorange.module.security.dto.LoginDto;
import com.yaorange.module.security.service.AuthService;
import com.yaorange.module.security.vo.ResourceVo;
import com.yaorange.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@Slf4j
public class AuthController {
    @Autowired
    private AuthService authService;
    @PostMapping("/login")
    public Result<String> login(@RequestBody LoginDto loginDto) {
        log.info("用户登录:"+loginDto);
        return Result.success(authService.login(loginDto));
    }

    @GetMapping("/info")
    public Result<ResourceVo> getResource(){
        log.info("获取用户信息");
        return Result.success(authService.getResource());
    }
}
